package sala.commonmovie.bottommenu 
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import sala.events.BottomMenuEvent;
	/**
	 * ...
	 * @author zacess
	 */
	public class BottomMenuItem extends MovieClip
	{
		public var Tf:TextField; 
		private var _active: Boolean = false;
		
		public function BottomMenuItem() 
		{
			this.mouseChildren = false;
			this.buttonMode = true; 
			
			this.addEventListener(MouseEvent.CLICK, mouseClickHdl); 
			this.addEventListener(MouseEvent.ROLL_OUT, mouseRollOutHdl); 
			this.addEventListener(MouseEvent.ROLL_OVER, mouseRollOVerHdl); 
		}
		
		private function mouseRollOVerHdl(e:MouseEvent):void 
		{
			this.Tf.textColor = 0x1667B2; 
		}
		
		private function mouseRollOutHdl(e:MouseEvent):void 
		{
			if (!active) this.Tf.textColor = 0x888888; 
		}
		
		private function mouseClickHdl(e:MouseEvent):void 
		{
			if (!active)
			{
				this.Tf.textColor = 0xF4781F; 
				var evt:BottomMenuEvent = new BottomMenuEvent (BottomMenuEvent.MENU_BUTON_CLICK); 
				evt.itemName = e.currentTarget.name; 
				dispatchEvent(evt); 
			}
			else this.mouseEnabled = false; 
		}
		
		public function get active():Boolean { return _active; }
		
		public function set active(value:Boolean):void 
		{
			_active = value;
			if (value)
			{
				this.Tf.textColor = 0xF4781F;
				this.mouseEnabled = false; 
			}
			else
			{
				this.Tf.textColor = 0x888888;
				this.mouseEnabled = true; 
			}
		}		
	}

}